<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>图片总数--layui后台管理模板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../css/public.css" media="all" />
</head>
<style>
    .am-form-file {
        position: relative;
        overflow: hidden;
    }
    
    .am-form-file input[type=file] {
        position: absolute;
        z-index: 1;
        width: 100%;
        font-size: 50rem;
        opacity: 0;
        cursor: pointer;
    }
    
    #fileBtn {
        margin-left: 13%;
        margin-top: 15px
    }
    
    #fileBtn input[type="file"] {
        background: #ffffff;
        border: none;
    }
</style>

<body class="">




    <form id="qianhuaform" class="layui-form layui-row" method="post" action="https://www.logclub.com/xahh/1/index.php?method=insert_lunbo_data" enctype="multipart/form-data">
        <div class="layui-col-md9 layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label">轮播图标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" required lay-verify="required" placeholder="请输入轮播图标题" autocomplete="off" class="layui-input">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">轮播图片</label>
                <div class="layui-upload-list thumbBox mag0 magt3">
                    <img class="layui-upload-img thumbImg" id="xiaohuahua">

                    <!-- <input type="file" name="uploadFile" id="inputImg" onchange="imginput()" class="layui-upload-img thumbImg"> -->
                </div>
                <div id="fileBtn">
                    <input type="file" onchange="previewImage(this)" value="选择图片" name="uploadFile" id="inputImg" class="layui-upload-img thumbImg">

                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">选择招聘信息</label>
                <div class="layui-input-block">

                    <!-- <input type="text" name="recruit_id" value="654321"> -->


                    <select name="recruit_id" lay-verify="required" class="selects">
                                  <option value=""></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <!-- <button>jlkjaklsdjklfjaklsd</button>
                    <div style="width:100px; height:100px; border:10px solid red;"></div> -->
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>







    </form>

    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script type="text/javascript" src="addLunBo.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>


    <script type="text/javascript" src="../../js/jquery.js"></script>

    <script type="text/javascript" src="../../js/jquery.form.min.js"></script>



    <script>
        function previewImage(fileDom) {
            //判断是否支持FileReader
            if (window.FileReader) {
                var reader = new FileReader();
            } else {
                alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
            }

            //获取文件
            var file = fileDom.files[0];

            var imageType = /^image\//;
            //是否是图片
            if (!imageType.test(file.type)) {
                alert("请选择图片！");
                return;
            }
            //读取完成
            reader.onload = function(e) {
                //获取图片dom
                var img = document.getElementById("xiaohuahua");
                //图片路径设置为读取的图片
                img.src = e.target.result;
            };

            reader.readAsDataURL(file);

        }

        $('#qianhuaform').on('submit', function(e) {
            e.preventDefault();

            console.log("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")
            console.log(this)
            $(this).ajaxSubmit({


                success: function(result) {
                    console.log("kkkkkkkk")
                    console.log(result)

                    // window.location.reload()
                    setTimeout(function() {
                        console.log($("#inputImg").val())
                            // top.layer.close(index);

                        top.layer.msg("轮播图添加成功！");
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    }, 500);



                    // window.location.reload()
                },
                error: function(err) {
                    window.location.reload()
                }
            })
        });
        //Demo
        // layui.use('form', function() {
        //     var form = layui.form;

        //     //监听提交
        //     form.on('submit(formDemo)', function(data) {
        //         console.log("5555")
        //         layer.msg(JSON.stringify(data.field));
        //         return false;
        //     });
        // });
    </script>

</body>

</html>